package com.qianfeng.shopping.controller;

import com.alibaba.fastjson.JSON;
import com.qianfeng.shopping.dao.CountTimeDao;
import com.qianfeng.shopping.dao.LocationDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "CountTimesServlet", value = "/CountTimesServlet")
public class CountTimesServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        String flag = request.getParameter("flag");
        CountTimeDao dao = new CountTimeDao();
        response.setHeader("Context-type","text/plain,charset=utf-8");
        PrintWriter pw = response.getWriter();
        String str =  JSON.toJSONString(dao.selectAll());
        System.out.println(str);
        pw.write(str);
        pw.close();
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
